# -- coding: utf-8 --
from tools.Request_General import BaseAPI


class VARIABLE(BaseAPI):
    """
    变量组件相关接口
    """

    def save_variables(self, payload):
        """保存变量数据接口"""
        r = self.request_send(json=payload)
        return r

    def get_variables(self, payload):
        """查询变量列表接口"""
        r = self.request_send(params=payload)
        return r

    def update_variables(self, payload):
        """更新变量列表接口"""
        r = self.request_send(json=payload)
        return r

    def give_variable_api(self, payload):
        """对外提供变量名列表接口"""
        r = self.request_send(params=payload)
        return r

    def get_variable_value(self, payload):
        """根据变量名称获取变量对应值"""
        r = self.request_send(params=payload)
        return r

    def variable_value_batch(self, payload):
        """
        根据多个变量元素的多个变量名称查询变量对应值
        """
        r = self.request_send(json=payload)
        return r

    def get_relation(self, payload):
        """
        查询关联元素信息
        """
        r = self.request_send(params=payload)
        return r

    def save_relation(self, payload):
        """
        保存关联元素信息
        """
        r = self.request_send(json=payload)
        return r

    def copy_variable_callback(self, payload):
        """
        复制变量后置通知
        """
        r = self.request_send(json=payload)
        return r

    def import_variable_callback(self, payload):
        """
        导入变量后置通知
        """
        r = self.request_send(json=payload)
        return r

    def check_table(self, payload):
        """
        校验变量元素数据表是否存在
        """
        r = self.request_send(params=payload)
        return r

    def variable_members(self, payload):
        """
        查询变量元素成员接口
        """
        r = self.request_send(json=payload)
        return r

    def variables(self, payload):
        """
        变量列表接口
        """
        r = self.request_send(params=payload)
        return r

    def upgrade_variable(self, payload):
        """
        变量元素1.0升级至1.1
        """
        r = self.request_send(json=payload)
        return r


if __name__ == '__main__':
    import pprint

    t = VARIABLE(headers={
        "cookie": "test_deepfos_users=%7B%22color%22%3A%221%22%2C%22email%22%3A%22tianhao.wang%40proinnova.com.cn%22%2C%22invitationActivation%22%3Atrue%2C%22nickName%22%3A%22wth%22%2C%22nickname%22%3A%22wth%22%2C%22token%22%3A%22E1EAAFB7F4BB1631368EC55F3E40D350BA725D75FBA18815E13AA97B5865947A%22%2C%22tokenKey%22%3A%22test_deepfos_token%22%2C%22type%22%3A1%2C%22userId%22%3A%22b72c8c12-2595-48fd-993d-60e5e09e08eb%22%2C%22username%22%3A%22wth2%22%7D; test_deepfos_token=E1EAAFB7F4BB1631368EC55F3E40D350BA725D75FBA18815E13AA97B5865947A; deepfos_users=%7B%22color%22%3A%225%22%2C%22email%22%3A%22auto.sys%40proinnova.com.cn%22%2C%22invitationActivation%22%3Atrue%2C%22token%22%3A%225A319A88C3FB56FB4A799A9001950F63137DC87E507E97527DB3EA5DA59A9255%22%2C%22tokenKey%22%3A%22deepfos_token%22%2C%22type%22%3A1%2C%22userId%22%3A%22b40bee35-105e-407a-8404-b1b4eedac75e%22%2C%22username%22%3A%22auto.sys%22%7D; deepfos_token=5A319A88C3FB56FB4A799A9001950F63137DC87E507E97527DB3EA5DA59A9255",
        "app": "llbtwa004",
        "space": "llbtwa"}, version="1.0").get_variable_value(payload=
    {
        "elementName": "Testvariables",
        "folderId": "",
        "path": "\\12",
        "name": "setup_class_G"
    }
    )
    pprint.pprint(t.json())
